#ifndef     __SENSOR_H
#define     __SENSOR_H

#include <stdint.h>
#include "../utils/nocopyable.h"
#include "../utils/object.h"

namespace cargo_driver {

class Sensor : public Object<Sensor>, private NoCopyable {

public:
    void init();

    uint16_t adc_value();

    bool is_comp_checked() {
        return (read() & 0x01) == 0;
    }

    bool is_pick_box_up() {
        return (read() & 0x04) != 0;
    }

    bool is_pick_box_down() {
        return (read() & 0x08) != 0;
    }

    bool is_pick_motor_origin() {
        return (read() & 0x10) != 0;
    }

    bool is_btn_click() {
        return (read() & 0x40) == 0;
    }

    bool is_cargo_origin() {
        return (read() & 0x80) != 0;
    }

    static uint8_t read();
};

extern Sensor sensor;

}


#endif
